<template>
	<scroll-view class="scroll-view" scroll-y @scrolltolower="getList">
		<view class="detail-box">
			<empty top="40vh" v-if="pageList.length==0" />
			<dataDetail v-for="(item,i) in pageList" :key="i" :items="item"
				:detail="(item.itemCode=='ybcs'||item.itemCode=='pljs')&&!!item.infractRecordId" @detail="detail(item)" />
		</view>
	</scroll-view>
</template>
<script>
	import dataDetail from "@/components/tool-card/data-detail";
	import empty from "@/components/tool-empty/empty";
	import {
		cycle_persion_detail,
	} from '@/common/api/req.js'
	export default {
		components: {
			dataDetail,
			empty
		},
		data() {
			return {
				list: [],
				current: 0,
				pageList: [],
			}
		},
		computed: {
			total() {
				return this.list.length;
			},
		},
		methods: {
			getList() {
				this.current++;
				let end = this.current * 20;
				let start = end - 20;
				const addList = this.list.slice(start, end);
				// console.log(addList);
				this.pageList.push(...addList);
			},
			detail(item) {
				console.log(item);
				let params = "indicatorItem=" + item.indicatorItem;
				params += "&itemCode=" + item.itemCode;
				params += "&infractRecordId=" + item.infractRecordId;
				params += "&occurAddr=" + item.occurAddr;
				this.$goBack('./evidence-detail?' + params)
			},
		},
		onLoad(e) {
			// console.log(e);
			const tempData = this.$store.getters.get_temp;
			let item;
			if (e.type == 'history') {
				item = tempData.historyCycle[e.i];
			} else {
				item = tempData.currentCycle[e.i];
			}
			// console.log(item);
			// 设置当前查看的扣分详情类型
			uni.setNavigationBarTitle({
				title: item.indicatorItem
			})
			if (item.archiveDetailVOList.length) {
				cycle_persion_detail(item.archiveDetailVOList).then(res => {
					this.list = res.data.data;
					console.log(this.list);
					this.getList();
				})
			}
		},
	}
</script>
<style lang="scss">
	.scroll-view {
		height: 100vh;

		.detail-box {
			box-sizing: border-box;
			padding: 30rpx;
			background: #f2f2f2;
			position: relative;
			min-height: 100vh;

			.item-box {
				margin-bottom: 30rpx;
			}
		}
	}
</style>